package coint.btc.service.auth.impl;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import coint.btc.dto.JueseDTO;
import coint.btc.jpa.jueseJpa;
import coint.btc.pojo.Juese;
import coint.btc.service.auth.JueseService;
import coint.btc.vo.JueseVo;
import coint.btc.vo.Page;


/***
 * 
* @Title: DaozhaJueseServiceImpl 

* @Description:角色信息服务 

* @author wyx  

* @date 2018年7月13日
 */
@Service
public class JueseServiceImpl implements JueseService {

	@Autowired	
	private jueseJpa juesejpa;
	
	@Override
	public void addJuese(JueseDTO juese) {
		
		try {
			Juese  toben = new Juese();
			if(juese!=null) {
				BeanUtils.copyProperties(juese, toben);
			}
			juesejpa.addJuese(toben);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		

	}
	
	@Override
	public void deleteJueseByid(Integer id) {
		try {
			juesejpa.delete(id);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public int updateJuese(JueseDTO juese) {
		try {
			
			Juese  toben =new Juese();
			if(juese!=null) {
				BeanUtils.copyProperties(juese, toben);
			}
			
			
			juesejpa.updateJuese(toben);
		} catch (Exception e) {
			e.printStackTrace();
			return 0;
		}
		
		return 1;
		
	}

	@Override
	public JueseVo findJueseInfoVoById(Integer id) {
		
		Juese temp = juesejpa.findJueseByid(id);
		JueseVo vo  = new JueseVo();
		if(temp!=null) {
			BeanUtils.copyProperties(temp, vo);
		}
		
		 return vo;
	}
	
	@Override
	public Page<JueseVo> findJuesePageByParms(Page<JueseVo> page, JueseDTO parms) {
		
		return juesejpa.findJuesePageByParms(page, parms);
	}

}
